import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author Roderland
 * @since 1.0
 */
public class Test {
    public static void main(String[] args) {
        String s1 = "push   %ebp";
        String s2 = "mov    (%esp),(%ebp)";
        String s3 = "add    ($0x2e23),%eax";
        String s4 = "mov    ($0x3),%eax";
        String s5 = "pop    %ebp";
        String s6 = "ret";

        // 分组且创建反向引用
        Pattern pattern = Pattern.compile("(\\w+)(\\s)*+((%\\w+|\\$0x[0-9A-Fa-f]+)|(\\((%\\w+|\\$0x[0-9A-Fa-f]+)\\)))*(,((%\\w+)|(\\(%\\w+\\))))*");
        Matcher matcher = pattern.matcher(s3);
        while (matcher.find()) {
            System.out.println(matcher.group(0));
            System.out.println(matcher.group(1));
            //System.out.println(matcher.group(2));
            System.out.println(matcher.group(3));
            //System.out.println(matcher.group(4));
            System.out.println(matcher.group(8));
        }

        System.out.println(Integer.parseInt("f", 16));
    }
}
